package org.infodavid.common.model;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.infodavid.common.IObjectFactory;
import org.infodavid.common.persistence.IBasicDataObject;
import org.infodavid.common.reflect.InstantiationHelper;

/**
 * The Class ModelFactory.
 */
public abstract class ModelFactory implements IObjectFactory<IBasicDataObject> {

	/** The Constant LOGGER. */
	private static final Log LOGGER = LogFactory.getLog(ModelFactory.class);

	/** The singleton. */
	protected static final ModelFactory SINGLETON;

	static {
		try {
			SINGLETON = InstantiationHelper.getInstance().newInstance(ModelFactory.class);
		}
		catch (final Exception e) {
			LOGGER.fatal("Can not instantiate the " + ModelFactory.class.getName(), e);

			throw new Error(e);
		}
	}

	/**
	 * Gets the instance.
	 * @return the factory.
	 */
	public static ModelFactory getInstance() {
		return SINGLETON;
	}

	/**
	 * The constructor.
	 * @throws NoSuchMethodException the exception
	 */
	protected ModelFactory() throws NoSuchMethodException {
		super();
	}
}
